fix(webapp): seed selectedChainIds from validChainIds when empty#2786
fix(webapp): seed selectedChainIds from validChainIds when empty#2786thedavidmeister wants to merge 2 commits into
Conversation
Fresh users and users who cleared localStorage had selectedChainIds=[] after app init. validChainIds.subscribe only filtered stale IDs but never seeded an empty selection, so no orders were visible without a wallet. When validChainIds first populates and selectedChainIds is empty, set it to all valid chain IDs so orders are browsable wallet-disconnected. Returning users keep their stored selection unchanged. Closes #2747 Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughA one-line early-return is added to the ChangesChain ID auto-seeding logic and tests
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…-orders-without-wallet
What
Orders page showed nothing for fresh/wallet-disconnected users because
selectedChainIdsstarted as[]and no code ever seeded it.validChainIds.subscribeonly filtered stale entries — it never auto-selected chains for users with an empty selection. Connecting a wallet didn't directly fix this either (the wallet setschainId, notselectedChainIds). In practice, users only saw orders if they had a prior chain selection persisted in localStorage, which is why the issue correlates with wallet connection: the wallet flow incidentally triggers a chain-selection UI.Fix
One-line guard in
validChainIds.subscribe: whenvalidChainIdsfirst becomes non-empty andselectedChainIdsis empty, seedselectedChainIdswith all valid chain IDs. Returning users (non-emptyselectedChainIdsin localStorage) keep their stored selection unchanged.validChainIds.subscribe((valid) => { if (valid.length > 0) { selectedChainIds.update((current) => { + if (current.length === 0) return [...valid]; const filtered = current.filter((id) => valid.includes(id)); return filtered.length !== current.length ? filtered : current; }); } });Tests
Two new unit tests in
settings.test.ts:seeds selectedChainIds with all validChainIds when selectedChainIds is empty— fresh-user pathdoes not re-seed selectedChainIds when validChainIds updates and selectedChainIds is already set— returning-user path (no clobber)All seven existing pruning/persistence tests continue to pass.
Closes #2747
Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit